<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<script type="text/javascript" src="lib/PIE_IE678.js"></script>
<![endif]-->
<link href="css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="css/H-ui.admin.css" rel="stylesheet" type="text/css" />
<link href="lib/icheck/icheck.css" rel="stylesheet" type="text/css" />
<link href="lib/Hui-iconfont/1.0.6/iconfont.css" rel="stylesheet"
	type="text/css" />
<link href="lib/webuploader/0.1.5/webuploader.css" rel="stylesheet"
	type="text/css" />
<!-- <link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.css"
	rel="stylesheet" type="text/css" /> -->
<link href="lib/region/css/city-picker.css" rel="stylesheet"
	type="text/css" />
<link href="lib/region/css/main.css" rel="stylesheet" type="text/css" />

  <link href="css/bootstrap.css" rel="stylesheet">
  <script src="js/jquery.js"></script> 
  <script src="js/bootstrap.js"></script> 
  <link href="http://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.2/summernote.css" rel="stylesheet" >
  <script src="js/summernote.js"></script>
<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>发布新发现活动</title>
</head>
<body>
	<div class="pd-20">
		<form action="<%=path%>/backstage/activity_discover-add"
			method="post" class="form form-horizontal" id="form-u_discover-add">
			<input type="hidden" id="id" name="id" value='${u_discover.id}' />

			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">活动类型：</label>
				<div class="formControls col-xs-8 col-sm-5">
					<span class="select-box"> <select name="cateId"
						class="select" datatype="*" nullmsg="不能为空">
							<option value="">----</option>
							<c:forEach items="${cates}" var="cate">
								<option value="${cate.id}"
									<c:if test="${cate.id==u_discover.activity_type}">selected</c:if>>${cate.cate_name}</option>
							</c:forEach>
					</select>
					</span>
				</div>
			</div>

		  <div class="row cl">
        	<label class="form-label col-xs-4 col-sm-3"></label>
			<input type="hidden" id="vedio" name="vedio" value="${u_discover.vedio}" />	
			<div class="formControls col-xs-8 col-sm-5" id="show_type">
			<c:if test="${!empty u_discover.vedio}">		
				<audio controls="controls">
					<source src="${u_discover.vedio}" type="audio/mpeg">
				</audio>
			</c:if>	
									
			</div>			
		</div>
		
		
			<div class="row cl">
				
				<input type="hidden" id="image_list_del"
						name="image_list_del" value="" />
					<label class="form-label col-xs-4 col-sm-3">活动音乐：</label>		
					<div class="formControls col-5">
						<div class="uploader-list-container">
							<div class="queueList">
								<div id="dndArea" class="placeholder">
									<div id="filePicker-2"></div>
									
								</div>
							</div>
							<div class="statusBar" style="display: none;">
								<div class="progress">
									<span class="text">0%</span> <span class="percentage"></span>
								</div>
								<div class="info"></div>
								<div class="btns">
									<div id="filePicker2"></div>
									<div class="uploadBtn">开始上传</div>
								</div>
							</div>
						</div>
					</div>
	       	 	</div>
   		
		
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">添加海报：</label>
			<div class="formControls col-xs-8 col-sm-5">
				<div id="fileList_pre" class="uploader-list">
				<c:if test="${!empty u_discover.head_img}">
				<div  class="file-item thumbnail">
					<img src="${u_discover.head_img}" height="50" border="0" /> 
				</div>
				</c:if>
				</div>
				<div id="filePicker_pre">添加海报</div>
				<input type="hidden" class="input-text"
				value="${u_discover.head_img}" placeholder=""
				id="head_img" name="head_img">
			</div>
		</div>
		
        
		<%-- 	<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">添加音乐：</label>
				<div class="formControls col-xs-8 col-sm-5">
					<input type="text" class="input-text" value="${u_discover.vedio}"
						placeholder="" id="vedio" name="vedio" datatype="*" nullmsg="不能为空">
				</div>
			</div> --%>

			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">活动主题：</label>
				<div class="formControls col-xs-8 col-sm-5">
					<input type="text" class="input-text" value="${u_discover.title}"
						placeholder="" id="title" name="title" datatype="*" nullmsg="不能为空">
				</div>
			</div>

			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">投放地区：</label>
				<div class="formControls col-xs-8 col-sm-5">
					<input id="city-picker3" class="form-control" readonly
						name="regioninfo" type="text" value="${u_discover.city}" data-toggle="city-picker">
				</div>
			</div>

			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">详细地址：</label>
				<div class="formControls col-xs-8 col-sm-5">
					<input type="text" class="input-text" value="${u_discover.address}"
						placeholder="" id="address" name="address" datatype="*"
						nullmsg="不能为空">
				</div>
			</div>

			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">广告开始时间：</label>
				<div class="formControls col-xs-8 col-sm-5">
					<input type="text" class="input-text Wdate"
						onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"
						value="${u_discover.begin_time}" placeholder="" id="begin_time"
						name="begin_time" datatype="*" nullmsg="不能为空">
				</div>
			</div>

			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">广告结束时间：</label>
				<div class="formControls col-xs-8 col-sm-5">
					<input type="text" class="input-text Wdate"
						value="${u_discover.end_time}"
						onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"
						placeholder="" id="end_time" name="end_time" datatype="*"
						nullmsg="不能为空">
				</div>
			</div>

		<%-- 	<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">活动说明：</label>
				<div class="formControls col-xs-8 col-sm-5">
					<textarea class="input-text" placeholder="" style="height: 50px"
						id="" name="description">${u_discover.description}</textarea>
				</div>
			</div> --%>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">活动说明：</label>
			<input type="hidden" id="description" name ="description" >
			<div class="formControls col-xs-8 col-sm-5">
		 		<div id="summernote" class="input-text">${u_discover.description}</div>
		 	</div>
		</div> 
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">活动费用</label> <label
					class="form-label col-xs-4 col-sm-5"><button
						onClick="add_new_charge();" class="btn btn-success radius"
						type="button">
						<i class="Hui-iconfont">&#xe632;</i> 增加费用
					</button></label> <label class="form-label col-xs-4 col-sm-3"></label>
			</div>

			<div class="row cl">
				<label class="form-label col-xs-2 col-sm-1">&nbsp;</label> <label
					class="col-xs-10 col-sm-8">
					<table id="charge" class="table">
						<thead>
							<tr>
								<th class="col-xs-1">#</th>
								<th class="col-xs-3">费用名称</th>
								<th class="col-xs-1">金额</th>
								<th class="col-xs-2">人数上限</th>
								<th class="col-xs-1"></th>
							</tr>
						</thead>
						<tbody>
							<c:forEach items="${specs}" var="spec">
								<tr>
									<td class='col-xs-1'></td>
									<td class='col-xs-3'><input type='text'
										class='form-control' style='min-width: 10px'
										name='chargenames' datatype='*1-50' nullmsg='不能为空并且不得超过50个字符'
										value="${spec.price_name}"></td>
									<td class='col-xs-1'><input type='text'
										class='form-control' style='min-width: 10px' name='chargefees'
										
										nullmsg='不能为空并且必须是两位小数或整数' value="${spec.price}"></td>
									<td class='col-xs-2'><input type='text'
										class='form-control' style='min-width: 10px'
										name='chargelimits' datatype='n1-10' nullmsg='不能为空并且必须是整数'
										value="${spec.limit}"></td>
									<td class='col-xs-1'><button
											class='btn btn-warning radius' type='button'>
											<i class='fa fa-remove'>&#xe632;</i> 删除
										</button></td>
								</tr>
							</c:forEach>
						</tbody>
					</table>
				</label>
			</div>

			<div class="row cl">
				<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
					<button onClick="u_discover_save_submit();"
						class="btn btn-primary radius" type="submit">
						<i class="Hui-iconfont">&#xe632;</i> 保存并提交
					</button>
					<button onClick="layer_close();" class="btn btn-default radius"
						type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
				</div>
			</div>

		</form>
	</div>
<!-- 	<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script> -->
	<script type="text/javascript" src="lib/layer/2.1/layer.js"></script>
	<script type="text/javascript"
		src="lib/Validform/5.3.2/Validform.min.js"></script>
	<script type="text/javascript"
		src="lib/webuploader/0.1.5/webuploader.min.js"></script>
	<script type="text/javascript"
		src="lib/ueditor/1.4.3/ueditor.config.js"></script>
	<script type="text/javascript"
		src="lib/ueditor/1.4.3/ueditor.all.min.js"></script>
	<script type="text/javascript" src="lib/region/js/city-picker.data.js"></script>
	<script type="text/javascript" src="lib/region/js/city-picker.js"></script>
	<script type="text/javascript" src="lib/region/js/main.js"></script>
	<script type="text/javascript" src="lib/My97DatePicker/WdatePicker.js"></script>
	<script type="text/javascript" src="js/u_discover.js"></script>
	<script type="text/javascript">
$(document).ready(function(){
	
	 $('#summernote').summernote({
		  height: 150    });
	$('#charge').find('tbody tr').each(function(){
		var rowIndex = $(this).index() + 1;
		$(this).find('td:eq(0)').text(rowIndex);
		$(this).find('td:eq(4)').find('button').on('click', function(){
			$(this).parent().parent().remove();
			$('#charge').find('tbody tr').each(function(){
				var rowIndex = $(this).index() + 1;
				$(this).find('td:eq(0)').text(rowIndex);
			})
		});
	})	
});

function u_discover_save_submit(){
	document.getElementById("description").value = $('#summernote').summernote('code');	
	if ($('#charge').find('tbody tr').length == 0) {
		alert('需要设置活动费用');
		return false;
	}
	$("#form-u_discover-add").Validform({
		tiptype:2,
		ajaxPost:true,
		callback:function(form){
			var index = parent.layer.getFrameIndex(window.name);
			if (index){//关闭弹出层
				parent.$('.btn-refresh').click(); 
				parent.layer.close(index);
			}else{//单独的页面
				location.href = "<%=path%>/backstage/u_activity_discover-list"; 
			}
		}
	}); 
}

$(function() {
	/*外页上传*/
	var $list = $('#fileList_pre'),

	ratio = window.devicePixelRatio || 1,
	thumbnailWidth = 100 * ratio,
	thumbnailHeight = 100 * ratio,
	uploader3;

	uploader3 = WebUploader.create({
		auto: true,
		swf: 'lib/webuploader/0.1.5/Uploader.swf',
		server: '/uthink-backstage/backstage/common/uploadPic',
		pick: '#filePicker_pre',
		chunked: false,
        chunkSize: 512 * 1024,
        disableGlobalDnd: true,
        fileNumLimit: 300,
        fileSizeLimit: 200 * 1024 * 1024, 
		formData : {
			foldername : 'resource'
		}
	});
	  uploader3.on('dialogOpen', function() {
          console.log('here');
      });

      // 添加“添加文件”的按钮，
      uploader3.addButton({
          id: '#filePicker3',
          label: '继续添加'
      });

      uploader3.on('ready', function() {
          window.uploader3 = uploader3;
      });
      
	uploader3.on( 'fileQueued', function( file ) {
			$('#fileList_pre').empty();
			var $li = $(
				'<div id="' + file.id + '" class="file-item thumbnail">' +
				'<img>' +
				'<div class="info">' + file.name + '</div>' +
				'</div>'
				),
			$img = $li.find('img');
	
			$list.append( $li );
			uploader.makeThumb( file, function( error, src ) {
				if ( error ) {
					$img.replaceWith('<span>不能预览</span>');
					return;
				}
					//$('#pre_img').attr( 'src', src );
					$img.attr( 'src', src );
			}, thumbnailWidth, thumbnailHeight );	
		
	});

	uploader3.on( 'uploadSuccess', function(file, response) {
		$( '#'+file.id ).addClass('upload-state-done');
		document.getElementById("head_img").value = response.datas;			
		
					
	});

	uploader3.on( 'uploadError', function( file ) {
		var $li = $( '#'+file.id ),
		$error = $li.find('div.error');
		if ( !$error.length ) {
			$error = $('<div class="error"></div>').appendTo( $li );
		}

		$error.text('上传失败');
	});

	uploader3.on( 'uploadComplete', function( file ) {
		$( '#'+file.id ).find('.progress').remove();
	});
});


		function add_new_charge() {
			var rowLen = $('#charge').find('tbody tr').length + 1;
			var html = "<tr><td class='col-xs-1'>"
					+ rowLen
					+ "</td><td class='col-xs-3'><input type='text' class='form-control' style='min-width:10px' name='chargenames' datatype='*1-50' nullmsg='不能为空并且不得超过50个字符'></td><td class='col-xs-1'><input type='text' class='form-control' style='min-width:10px' name='chargefees'  nullmsg='不能为空并且必须是两位小数或整数'></td><td class='col-xs-2'><input type='text' class='form-control' style='min-width:10px' name='chargelimits' datatype='n1-10' nullmsg='不能为空并且必须是整数'></td><td class='col-xs-1'>"
					+ "<button class='btn btn-warning radius' type='button'><i class='fa fa-remove'>&#xe632;</i> 删除</button></td></tr>";
			$('#charge').find('tbody').append(html);
			$('#charge').find('tbody tr:last').find('button').on('click',
					function() {
						$(this).parent().parent().remove();
						$('#charge').find('tbody tr').each(function() {
							var rowIndex = $(this).index() + 1;
							$(this).find('td:eq(0)').text(rowIndex);
						})
					});
		}
	</script>
</body>
</html>

